package com.lecyon.farm.vo.sync;

import com.lecyon.farm.util.StringHelper;
import com.lecyon.farm.util.ValidateUtils;
import com.lecyon.farm.vo.base.BaseSyncVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 作业信息
 *
 * @author Yao Zheng
 * @Date 2020/4/14 12:22
 */
@Data
public class SyncMachineJob extends BaseSyncVo {

    @ApiModelProperty(name = "w1", value = "作业类型")
    private Integer w1 = 42;

    @ApiModelProperty(name = "w2", value = "作业日期", required = true)
    private String w2;

    @ApiModelProperty(name = "w3", value = "开始时间", required = true)
    private String w3;

    @ApiModelProperty(name = "w4", value = "结束时间", required = true)
    private String w4;

    @ApiModelProperty(name = "w5", value = "地块编号", required = true)
    private String w5;

    @ApiModelProperty(name = "w6", value = "深度点数", required = true)
    private Integer w6;

    @ApiModelProperty(name = "w7", value = "行驶里程", required = true)
    private Double w7;

    @ApiModelProperty(name = "w8", value = "作业里程", required = true)
    private Double w8;

    @ApiModelProperty(name = "w9", value = "作业地点经度", required = true)
    private Double w9 = 124.10;

    @ApiModelProperty(name = "w10", value = "作业地点纬度", required = true)
    private Double w10 = 42.78;

    @ApiModelProperty(name = "w11", value = "机具识别号", required = true)
    private String w11;

    @ApiModelProperty(name = "w12", value = "农具名称", required = true)
    private String w12 = "免耕播种";

    @ApiModelProperty(name = "w13", value = "作业幅宽（毫米）", required = true)
    private Integer w13;

    @ApiModelProperty(name = "w14", value = "作业面积(亩)", required = true)
    private Double w14;

    @ApiModelProperty(name = "w15", value = "作业合格面积(亩)", required = true)
    private Double w15;

    @ApiModelProperty(name = "w16", value = "重叠面积(亩)", required = true)
    private Double w16;

    @ApiModelProperty(name = "w17", value = "耕深(厘米)", required = true)
    private Double w17;

    @ApiModelProperty(name = "w18", value = "合格率(%)", required = true)
    private Double w18;

    @ApiModelProperty(name = "w19", value = "作业地点-省", required = true)
    private String w19 = "辽宁省";

    @ApiModelProperty(name = "w20", value = "作业地点-市", required = true)
    private String w20;

    @ApiModelProperty(name = "w21", value = "作业地点-区县", required = true)
    private String w21;

    @ApiModelProperty(name = "w22", value = "作业地点-具体位置", required = true)
    private String w22;

    @ApiModelProperty(name = "w23", value = "喷药量")
    private Double w23 = 0.0;

    @ApiModelProperty(name = "w24", value = "油耗/用电量")
    private Double w24 = 0.0;

    @ApiModelProperty(name = "w25", value = "播种量", required = true)
    private Double w25;

    @ApiModelProperty(name = "w26", value = "施肥量")
    private Double w26 = 0.0;

    @ApiModelProperty(name = "w27", value = "平均株距", required = true)
    private Double w27;

    @ApiModelProperty(name = "w28", value = "播种路数", required = true)
    private Double w28 = 1.0;

    @ApiModelProperty(name = "w29", value = "免耕覆盖率", required = true)
    private Double w29;

    @ApiModelProperty(name = "w30", value = "免耕播种秸秆覆盖状态（1合格 / 0不合格）", required = true)
    private String w30;

    @ApiModelProperty(name = "deviceId", value = "终端设备号")
    private String deviceId;


    public String getW11() {
        if (StringHelper.isEmpty(w11)) {
            return this.deviceId;
        }
        return w11;
    }

    public Double getW18() {
        if (ValidateUtils.isNotNullOrEmpty(w15) || ValidateUtils.isNotNullOrEmpty(w14)) {
            w18 = w15 / w14 * 100;
        }
        return w18;
    }

    public Double getW27() {
        if (ValidateUtils.isNotNullOrEmpty(w13)) {
            w27 = Double.parseDouble(w13.toString());
        }
        return w27;
    }

    public String getW30() {
        if (ValidateUtils.isNotNullOrEmpty(w29) && w29 > 0) {
            return "1";
        } else {
            return "0";
        }
    }
}
